#!/usr/bin/env bash

CONF_FILE=./conf/redis.conf

# 如果配置里没写 daemonize，Redis 会前台运行，docker 需要这个
grep -q '^daemonize yes' "$CONF_FILE" && {
  echo "请把 redis.conf 中的 daemonize 设为 no，否则容器会退出"
  exit 1
}

docker run -d --name redis-with-conf-6379 \
  -p 6379:6379 \
  -v "$CONF_FILE":/usr/local/etc/redis/redis.conf:ro \
  redis:latest \
  redis-server /usr/local/etc/redis/redis.conf